#include <iostream>

#include <gtest/gtest.h>

#include "melon/client/thrift_client_pool.h"
#include "bbt/adapters/bbt_customer_message_outlet_adapter.h"

#include "BbtServiceCommon_types.h"

using bbt::BbtCustomerMessageOutletServiceClient;
using melon::client::ClientPool;

using namespace bbt;

void * ThreadFun(void *) {
  for (int i = 0; i < 1; ++i) {
    BbtMessage msg;
    msg.sender = "MCode1234567890ABCDEF";
    msg.receiver = "12345";
    msg.body = "hello new framework.";
    int ret = BbtCustomerMessageOutletAdapter::Instance().PushMessage(msg, 2);
    std::cout << "Push Message " << i << " ret=" << ret << std::endl;

  //ImMessage message;
  //message.sender = 127646882 + i;
  //message.receiver = 127646882;
  //message.body = "bang_robot_test_message";
  //ret = BangRobotAdapter::Instance().DispatchMessage(message, 2);
  //std::cout << "DispatchMessage " << i << " ret=" << ret << std::endl;
  }
  return NULL;
}

const int kThreadCount = 20;

int main() {
  LOG_INIT("./test.log", "DEBUG");
  pthread_t ts[kThreadCount];

  for (int i = 0; i < kThreadCount; ++i) {
    pthread_create(&ts[i], NULL, ThreadFun, NULL);
  }

  for (int i = 0; i < kThreadCount; ++i) {
    pthread_join(ts[i], NULL);
  }
  return 0;
} 
